Boost C++ Application Development Cookbook by Unknown
Author:Unknown
Language: eng
Format: epub, pdf
Publisher: Packt Publishing
Executing different tasks in parallel
Now it is time to make our tasks_queue process tasks in multiple threads. How hard could this be?
Getting ready
You will need to read the first recipe from this chapter. Some knowledge of multithreading is also required, especially reading the Manipulating a group of threads recipe in Chapter 5, Multithreading.
How to do it...
All we need to do is to add the start_multiple method to our tasks_queue class:
#include <boost/thread/thread.hpp> // Default value will attempt to guess optimal count of threads void start_multiple(std::size_t threads_count = 0) { if (!threads_count) { threads_count = (std::max)(static_cast<int>( boost::thread::hardware_concurrency()), 1 ); } // one thread is the current thread -- threads_count; boost::thread_group tg; for (std::size_t i = 0; i < threads_count; ++i) { tg.create_thread(boost::bind( &boost::asio::io_service::run, boost::ref(ios_) )); } ios_.run(); tg.join_all(); }
Download
Boost C++ Application Development Cookbook by Unknown.pdf
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
What's Done in Darkness by Kayla Perrin(26804)
The Ultimate Python Exercise Book: 700 Practical Exercises for Beginners with Quiz Questions by Copy(20671)
De Souza H. Master the Age of Artificial Intelligences. The Basic Guide...2024 by Unknown(20446)
D:\Jan\FTP\HOL\Work\Alien Breed - Tower Assault CD32 Alien Breed II - The Horror Continues Manual 1.jpg by PDFCreator(20444)
The Fifty Shades Trilogy & Grey by E L James(19306)
Shot Through the Heart: DI Grace Fisher 2 by Isabelle Grey(19259)
Shot Through the Heart by Mercy Celeste(19128)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 10 by Isuna Hasekura and Jyuu Ayakura(17292)
Python GUI Applications using PyQt5 : The hands-on guide to build apps with Python by Verdugo Leire(17227)
Peren F. Statistics for Business and Economics...Essential Formulas 3ed 2025 by Unknown(17075)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 03 by Isuna Hasekura and Jyuu Ayakura & Jyuu Ayakura(16998)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 01 by Isuna Hasekura and Jyuu Ayakura & Jyuu Ayakura(16615)
The Subtle Art of Not Giving a F*ck by Mark Manson(14616)
The 3rd Cycle of the Betrayed Series Collection: Extremely Controversial Historical Thrillers (Betrayed Series Boxed set) by McCray Carolyn(14309)
Stepbrother Stories 2 - 21 Taboo Story Collection (Brother Sister Stepbrother Stepsister Taboo Pseudo Incest Family Virgin Creampie Pregnant Forced Pregnancy Breeding) by Roxi Harding(13967)
Scorched Earth by Nick Kyme(12963)
Drei Generationen auf dem Jakobsweg by Stein Pia(11146)
Suna by Ziefle Pia(11071)
Scythe by Neal Shusterman(10556)